package com.anywhere.freightman.car.dao;

import com.anywhere.freightman.car.model.CarModel;
import com.anywhere.freightman.car.model.DriverModel;
import com.anywhere.freightman.common.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface CarDao extends BaseMapper<CarModel> {

    @Select("select * from car where car_number=#{carNumber}")
    CarModel getByCarNumber(@Param("carNumber") String carNumber);

    List<DriverModel> getDriverList(@Param("carId") Long carId);

    void bindDriver(@Param("carId") long carId,
                    @Param("driverId") long driverId);

    void removeAllDriver(@Param("carId") long carId);

    void removeDriver(@Param("carId") long carId,
                      @Param("driverId") long driverId);

    void removeDriverByDriverId( @Param("driverId") long driverId);

    List<CarModel> getListByCompanyId(@Param("companyId") Long companyId);

    List<CarModel> getTrailerListByCompanyId(@Param("companyId") Long companyId);
}
